﻿using Bird.Core.Infrastructure.DependencyManagement;
using Ninject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Bird.Core.Infrastructure
{
    public class BirdEngine : IEngine
    {
        ContainerManager _container;
        IKernel _kernel;
        public ContainerManager ContainerManager
        {
            get { return _container; }
        }

        public void Initialize()
        {
            _kernel = NinjectWebCommon.Bootstrapper.Kernel; 
            _container = new ContainerManager(_kernel);
        }

        public object Resolve(Type type)
        {
            return _container.Resolve(type);
        }

        public IEnumerable<object> ResolveAll(Type type)
        {
            return _container.ResolveAll(type);
        }


        public void OnHttpApplicationStart(System.Web.HttpApplication application)
        {
           
          DependencyResolver.SetResolver(new BirdDependencyResolver());

        }
         
        public IKernel Kernel
        {
            get { return _kernel; }
        }
    }
}
